#define _WIN32_DCOM
#include <windows.h>
#include <iostream.h>
#include "Component\component.h"

void main()
{
	CoInitialize(NULL);

	IMoniker* pClassMoniker;
	CreateClassMoniker(CLSID_InsideCOM, &pClassMoniker);

	IClassFactory* pClassFactory;

	BindMoniker(pClassMoniker, 0, IID_IClassFactory, (void**)&pClassFactory);

//	IBindCtx* pClassBindCtx;
//	CreateBindCtx(0, &pClassBindCtx);
//	pClassMoniker->BindToObject(pClassBindCtx, NULL, IID_IClassFactory, (void**)&pClassFactory);
//	pClassBindCtx->Release();
 
	ISum* pSum;
	pClassFactory->CreateInstance(NULL, IID_ISum, (void**)&pSum);

	int addition;
	pSum->Sum(23, 32, &addition);
	cout << "23 + 32 = " << addition << endl;

	pSum->Release();
	pClassFactory->Release();
	pClassMoniker->Release();

	CoUninitialize();
}